import request from '@/utils/request'

// 登录
export const login = function (data) {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}
// 发送验证码，每手机号每分钟1次
export const sendSms = function (mobile) {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`
  })
}
// 用户自己信息获取
export const getUserInfo = function () {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}
// 获取用户频道列表
export const getUserChannels = function () {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}
// 关注用户
export const addFollow = function (target) {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
// 取消关注用户
export const deleteFollow = function (target) {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`
  })
}
// 获取个人资料
export const getUserProfile = function () {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}
// 修改个人资料
export const updateUserProfile = function (data) {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}
// 修改头像
export const updateUserPhoto = function (data) {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}
